﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>驾驶技术网</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="/Styles/Site.css" rel="stylesheet" type="text/css" />
	<script src="/Scripts/jquery.min.161.js" type="text/javascript"></script>
	<script src="/Scripts/jquery.simplemodal.1.4.3.min.js" type="text/javascript"></script>
	<script src="/Scripts/comm.js" type="text/javascript"></script>
	<script src="/Scripts/site.js" type="text/javascript"></script>
	<!-- 板块js -->
	<script src="/Templates/parts.js" type="text/javascript"></script>
<style>
.list { width:100%; }
.list th { border-bottom: dotted 1px #aaa; text-align:left; }
.list td, .list th { padding:3px 0px 1px 16px; }
.list tr:nth-child(even) td { background-color: #f6f6f6; }
#pager { border-top: dotted 1px #aaa; text-align:left; }
</style>
</head>

<body>
	<form id="form1" class="page" runat="server">
	<%-- 页码信息 --%>
	<input type="hidden" id="htmPagerows" value="30" runat="server" /> <%-- 每页行数，从页面传到服务器 --%>
	<input type="hidden" id="htmPages" value="" runat="server" /> <%-- 页数，从服务器端初始化 --%>
	<input type="hidden" id="htmPage" value="" runat="server" /> <%-- 当前页，从服务器端初始化 --%>
	<input type="hidden" id="htmCid" value="" runat="server" /> <%-- 栏目编号，从服务器端初始化 --%>
	<%-- 页眉板块 --%>
	<script type="text/javascript">		document.write(jsonparts["10"]);</script>
	<!-- left menu -->
	<div class="pageleft">
		<!-- 热点推荐 -->
		<script type="text/javascript">			document.write(jsonparts["13"]);</script>
		<div class="separation10"></div>
		<script type="text/javascript"><!--
			google_ad_client = "pub-2733994180506707";
			/* 160x600, 创建于 10-6-3 */
			google_ad_slot = "6252507617";
			google_ad_width = 160;
			google_ad_height = 600;
		//-->
		</script>
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
	</div>
    <div class="pageright">
	<!-- 搜索 -->
	<script type="text/javascript">		document.write(jsonparts["17"]);</script>
		<div class="separation10"></div>
		<script type="text/javascript"><!--
			google_ad_client = "pub-2733994180506707";
			/* 160x600, 创建于 10-6-3 */
			google_ad_slot = "6252507617";
			google_ad_width = 160;
			google_ad_height = 600;
		//-->
		</script>
		<script type="text/javascript"
		src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
		</script>
	</div>

	
	<div class="column650">
		<div class="combox">
			<h5><a href="/">首页</a>
			<% int n1 = posrows.Count-1; for( int i = 0; i < n1; i++ )
	  { %>&gt;&gt; <a href="/ColumnList.aspx?cid=<%=posrows[i]["colID"]%>"><%=posrows[i]["colName"]%></a>
			<%
	  } %> &gt;&gt; <%=posrows[n1]["colName"]%>
			</h5>
	<table class="list" cellpadding="0" cellspacing="0">
		<%
			StringBuilder str = new StringBuilder(10000);
			int n = 0;
			if (columnRows.Count > 0)	// 栏目列表
			{
				str.Append("<tr><th>栏目标题</th>");
				foreach (System.Data.DataRow row in columnRows)
				{
					str.AppendFormat("<tr><td><a href='/ColumnList.aspx?cid={0}'>{1}</a></td></tr>", row["colID"], row["colName"]);
					n++;
				}
				for (int i = n; i < pgrows; i++)
				{
					str.Append("<tr><td>&nbsp;</td></tr>");
				}
			}
			else	// 文章列表
			{
				str.Append("<tr><th class='w150'>发布日期</th><th>文章标题</th>");
				foreach (System.Data.DataRow row in articleRows)
				{
					str.AppendFormat("<tr><td>{0}</td><td><a href='/Articles/{1}-{2}.htm'>{3}</td></tr>", row["artUpdateTime"], row["acidColumnID"], row["artID"], row["artTitle"]);
					n++;
				}
				for (int i = n; i < pgrows; i++)
				{
					str.Append("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>");
				}
			}
			Response.Write( str );
		%>

	</table>
	<div class="separation10"></div>
	<div id="pager"></div>
	<div class="separation10"></div>
	<script>
		HPages(
	{ ctrlid: "#pager",
		page: $("#htmPage").val(), // 要显示的页号，从0开始。
		pages: $("#htmPages").val(),
		pagenu: 13, // 底部显示13个页号
		gopage: function (pa) {
			window.location = "/ColumnList.aspx?cid=" + $("#htmCid").val() + "&page=" + pa;
		}
	});

	</script>
		</div>
	</div>
	<div class="separation10"></div>		
	<!-- 页脚 -->
	<script type="text/javascript">		document.write(jsonparts["15"]);</script>
	</form>
</body>
</html>


<script runat="server">
	protected string cid;	// 栏目ID
	protected hcms.Admin.Model model = hcms.Global.model;	// 方法集合
	protected DataRowCollection posrows;	// 当前位置
	protected DataRowCollection columnRows;	// 栏目集合
	protected DataRowCollection articleRows;	// 文章集合
	protected int pgrows;
	protected void Page_Load(object sender, EventArgs e)
	{
		pgrows = int.Parse(htmPagerows.Value);
		int pages = 0;
		int page = 1;
		if (Request["page"] != null)
			page = int.Parse(Request["page"]) + 1;
		cid = Request["cid"];
		columnRows = model.getColumnRows(cid, false, ref page, pgrows, ref pages);
		if (columnRows.Count == 0)
			articleRows = model.getArticleRows(cid, false, ref page, pgrows, ref pages);	// [in][out]page 页号从1开始
		posrows = model.getCurrentPos(cid);
		
		// 页面标题，格式：栏目名称 | ... | 驾驶技术网
		StringBuilder title = new StringBuilder(1000);
		int n = posrows.Count;
		for (int i = n - 1; i >= 0; i--)
		{
			title.Append(posrows[i]["colName"]);
			title.Append(" | ");
		}
		title.Append("驾驶技术网");
		Page.Title = title.ToString();

		htmPage.Value = (page - 1).ToString();	// htmPage 页号，从0开始
		htmPages.Value = pages.ToString();
		htmCid.Value = cid;

	}
</script>
